<template>
    <span>
        <Drawer title="培训经历" :closable="false" placement="right" v-model="work" width="60%">
            <Row>
                <Table :loading="loading" border :columns="columns" :data="data" sortable="custom" @on-sort-change="changeSort" @on-selection-change="showSelect" ref="table"></Table>
            </Row>
            <Row type="flex" justify="end" class="page">
                <Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10,20,50]" size="small" show-total show-elevator show-sizer></Page>
            </Row>
        </Drawer>
    </span>
</template>

<script>
    import {studentTrainList} from "@/api/bus";
    import circleLoading from "../../../my-components/circle-loading.vue";

    export default {
        name: "train-manage",
        components: {
            circleLoading,
        },
        data() {
            return {
                work: false,
                loading: false, // 表单加载状态
                operationLoading: false,
                drop: false,
                selectCount: 0, // 多选计数
                selectList: [], // 多选数据
                searchForm: {
                    pageNumber: 1, // 当前页数
                    pageSize: 10, // 页面大小
                    sort: "createTime", // 默认排序字段
                    order: "desc", // 默认排序方式
                    userId: ""
                },
                selectDate: null, //选择日期绑定modal
                columns: [
                    {
                        type: "index",
                        width: 60,
                        align: "center"
                    },
                    {
                        title: "培训机构名称",
                        key: "organization",
                        align: "center"
                    },
                    {
                        title: "培训机构编码",
                        key: "organizationNum",
                        align: "center"
                    },
                    {
                        title: "培训内容",
                        key: "organizationContent",
                        align: "center"
                    },
                    {
                        title: "培训开始时间",
                        key: "cultivatestartDate",
                        width: 180,
                        align: "center"
                    },
                    {
                        title: "培训结束时间",
                        key: "cultivateendDate",
                        width: 180,
                        align: "center"
                    }],
                data: [], // 表单数据
                total: 0 // 表单数据总数
            }
        },
        methods: {
            showDrawer(params){
                this.work = true;
                this.searchForm.userId = params;
                this.getDataList();
            },
            getDataList() {
                // 多条件搜索用户列表
                this.loading = true;
                studentTrainList(this.searchForm).then(res => {
                    this.loading = false;
                    if (res.status === true) {
                        this.data = res.data.rows;
                        this.total = res.data.total;
                    }
                });
            },
            changePage(v) {
                this.searchForm.pageNumber = v;
                this.getDataList();
            },
            changePageSize(v) {
                this.searchForm.pageSize = v;
                this.getDataList();
            },
            changeSort(e) {
                this.searchForm.sort = e.key;
                this.searchForm.order = e.order;
                if (e.order === "normal") {
                    this.searchForm.order = "";
                }
                this.getDataList();
            },
            showSelect(e) {
                this.selectList = e;
                this.selectCount = e.length;
            },
        },
        mounted() {
        }
    }
</script>
